<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
Route::get('foo', function () {
    return 'Hello World';
});
Route::get('user/{id}', function ($id) {
    return 'User '.$id;
});
Route::get('posts/{post}/comments/{comment}',function ($post,$comment){
    return 'POST:'.$post.' COMMENT:'.$comment;
});
Route::get('user/{name?}',function ($name = 'WangDaWei'){
    return $name;
});
//多请求路由
Route::match(['get','post'],'match/{id?}',function ($id = 'ID') {return $id;});
//相应所有得路由
Route::any('user/{name?}',function ($name = 'WangDaWei'){
    return $name;
});

//正则匹配
//Route::get('users/{name?}',function ($name = 'WangDaWei'){
//    return $name;
//})->where('name','[A-Za-z]+');
//多条件
Route::get('user3/id/{id}/name/{name?}',function ($id,$name = 'WDW'){
    return $id.'====='.$name;
})->where(['id'=>'[0-9]+','name'=>'[A-Za-z]+']);
//路由别名
Route::get('user111/center',['as'=>'center',function(){
    return route('center');
}]);


//控制器中代码和路由结合使用

Route::get('member/info/{id}','MemberController@info');
Route::get('test1',['uses'=>'StudentController@test1']);
Route::get('query1',['uses'=>'StudentController@query1']);
Route::get('query2',['uses'=>'StudentController@query2']);
Route::get('query3',['uses'=>'StudentController@query3']);
Route::get('query4',['uses'=>'StudentController@query4']);
Route::get('orm1',['uses'=>'StudentController@orm1']);
Route::get('orm2',['uses'=>'StudentController@orm2']);
Route::get('orm3',['uses'=>'StudentController@orm3']);
Route::get('orm4',['uses'=>'StudentController@orm4']);
Route::get('view',['uses'=>'StudentController@view']);
Route::get('urlTest',['as'=>'url','uses'=>'StudentController@urlTest']);
//不能用
//Route::get('member/info',array('users'=>'MemberController@info'));

//Route::any('member/info'.)

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');
